package gov.tax.rti.ext.hibernate;

import gov.tax.rti.core.util.DbConstants;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.cfg.DefaultNamingStrategy;

import com.bstek.dorado.core.Configure;

@SuppressWarnings("serial")
public class RtiDefaultNamingStrategy extends DefaultNamingStrategy {
	
	private static Log logger = LogFactory.getLog(RtiDefaultNamingStrategy.class);
	
	public String tableName(String tableName) {
		tableName = super.tableName(tableName);
		String aliasTableName = Configure.getString(DbConstants.TABLE_NAME_KEY_ + tableName, tableName);
		if(!StringUtils.equals(tableName, aliasTableName)){
			logger.info("Hibernate table["+tableName +"] alias ["+aliasTableName+"]");
		}else{
			logger.debug("Hibernate table["+tableName +"]");
		}
		return aliasTableName;
	}

}
